package com.bolovan.infovaluta.util;

import java.io.IOException;

import org.apache.log4j.Logger;

import com.bolovan.infovaluta.bean.ExchangeRate;
import com.bolovan.infovaluta.bean.ExchangeRateSeller;
import com.bolovan.infovaluta.reader.ReaderFactory;

public class RateMaps {

	public static String date = RateUtil.getNowAsLocalString();
	public static ExchangeRate bnr;
	public static ExchangeRate bce;
	public static ExchangeRate bcr;
	public static ExchangeRate bt;
	public static ExchangeRate ing;
	public static ExchangeRate brd;
	public static ExchangeRate raiffeisen;
	private static final Logger log = Logger
			.getLogger(RateMaps.class.getName());

	public static ExchangeRate parseMap(ExchangeRateSeller seller) {
		ExchangeRate rate = null;
		try {
			rate = new ExchangeRate(ReaderFactory.getReader(seller));
		} catch (IOException e) {
			log.error("Error reading maps" + e.getMessage());
		}
		return rate;
	}

	public static void parse() {
		bnr = parseMap(ExchangeRateSeller.BNR);
		bce = parseMap(ExchangeRateSeller.BCE);
		bcr = parseMap(ExchangeRateSeller.BCR);
		bt = parseMap(ExchangeRateSeller.BT);
		ing = parseMap(ExchangeRateSeller.ING);
		brd = parseMap(ExchangeRateSeller.BRD);
		raiffeisen = parseMap(ExchangeRateSeller.RAIFFEISEN);
	}
}
